package com.iheqing.test.app.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iheqing.test.app.entity.Log;
import com.iheqing.test.app.entity.Menu;
import com.iheqing.test.app.service.ILogService;
import com.iheqing.test.app.service.IMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 菜单管理 前端控制器
 * </p>
 *
 * @author iheqing@qq.com
 * @since 2020-03-15
 */
@Api(description = "测试服务接口")
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    IMenuService menuService;

    @Autowired
    ILogService logService;

    @GetMapping("/findMenu")
    public IPage<Menu> findMenu(@RequestParam(required = false) Integer parentId,@RequestParam(required = false) Integer type,Integer page,Integer pageSize){
        Page<Menu> pageObj = new Page<>(page,pageSize);
        return menuService.findMenu(pageObj,parentId,type);
    }

    @ApiOperation(value="添加菜单", notes="添加菜单")
    @PostMapping("/addMenu")
    public boolean addMenu(Menu menu){
        return menuService.save(menu);
    }

    @ApiOperation(value="添加日志", notes="添加日志")
    @PostMapping("/addLog")
    public boolean addLog(Log log){
        return logService.save(log);
    }



}
